package com.agileboot.admin.controller.system;


import com.agileboot.common.core.dto.ResponseDTO;
import com.agileboot.common.core.page.PageDTO;
import com.agileboot.domain.system.dict.DictApplicationService;
import com.agileboot.domain.system.dict.dto.DictTypeDTO;
import com.agileboot.domain.system.dict.query.DictTypeQuery;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/dict")
@RequiredArgsConstructor
public class SysDictController {

    private final DictApplicationService dictApplicationService;


    @PreAuthorize("@permission.has('dict:type:list')")
    @GetMapping("/type/list")
    public ResponseDTO<PageDTO<DictTypeDTO>> list(DictTypeQuery query) {
        PageDTO<DictTypeDTO> page = dictApplicationService.getDictTypeList(query);
        return ResponseDTO.ok(page);
    }
}
